<template>
	<view style="display: flex; background-color: lightblue;">
		<view class="weaItem">{{city}}</view>
		<view class="weaItem">{{highWendu}}</view>
		<view class="weaItem">{{lowWendu}}</view>
	</view>
	
	<view v-for="item in dataObj" style="margin: 10px;">
		<newsView
		:title="item.title" 
		:isTop="item.isTop" 
		:comments="item.comments" 
		:author="item.author"
		:time="item.time"
		:images="item.images"
		:isOneImg="item.isOneImg"
		:isguang="item.isguang">

		   <template v-slot:tips>
		     <view class="slotcontent" v-if="item.showSearch">
		       <text>搜索：</text>
		       <view class="borderbox"><text>今日金价</text></view>
		       <view class="borderbox"><text>双十一狂欢购</text></view>
		     </view>
		   </template>

        </newsView> 
	</view>
</template>

<script>
	import newsView from '../../../components/NewsCardView.vue'
	export default {
		data() {
			return {
				city:'无',
				highWendu:'无',
				lowWendu:'无',

				dataObj: [{
						title: "习近平同韩国总统李在明会谈",
						isTop: true,
						author: "界面新闻",
						comments: 5659,
						time: "2025.11.01"
					},
					{
						title: "泰州点球大战胜南通 夺苏超冠军",
						isTop: true,
						author: "百度热搜",
						comments: 1025,
						time: "2025.11.2",
						isOneImg: [
							'/static/newsimage/news2.png',
						]
					},
					{
						title: "外交部回应日本人领导人涉台错误言行",
						isTop: false,
						author: "人民日报",
						comments: 4452,
						time: "2025.10.31",
						showSearch : true,
						isOneImg: [
							'/static/newsimage/news3.png',
						]
					},
					
					{
						title: '加微信交友群，喜欢就聊，找喜欢的人',
						isTop: false,
						isguang:true,
						author: '交友群',
						conut: '465万',
						time: '2025-10-28',
						images:[
							'/static/add/a1.png',
							'/static/add/a2.png',
							'/static/add/a3.png',
						]
					},
					{
						title: "电诈头目陈志仍下落不明！新加坡出手：冻结8.2亿元资产，查封扣押6处房产、1艘游艇、11辆豪车",
						isTop: false,
						author: "红星新闻",
						comments: 2626,
						time: "2025.10.29",
						isOneImg: [
							'/static/newsimage/news5.png',
						]
					},
					{
						title: "第二届中信财富管理大会召开 共探财富管理行业转型路径与全球配置新机遇",
						isTop: false,
						author: "中国日报网",
						comments: 1156,
						time: "2025.11.2"
					}
				]
			}
		},

		onLoad() {
			this.getWeather()
		},

		onShow(){
			this.getWeather()
		},

		methods: {
            getWeather() {
				console.log(45687);
            	uni.request({	
            		url: 'http://t.weather.sojson.com/api/weather/city/101230501',
            		method: 'GET',
					header: {
						// 'Authorization': uni.getStorageSync('token'), // 携带登录凭证
						'Content-Type': 'application/x-www-form-urlencoded'
					},
            		// 接口必填参数
            		// data: {},
            		 
            		success: (res) => {
            			console.log('查询结果', res.data.message);
            
            			// 处理接口响应
						this.city = res.data.cityInfo.city
						this.highWendu = res.data.data.forecast[0].high
						this.lowWendu = res.data.data.forecast[0].low
            		},
            		fail: (err) => {
            			 console.log('6666666');
            		},
            		
            	})
			  }	

		},

		components: {
			newsView,
		}
	}
</script>

<style>
.weaItem{
	margin-left: 18px;
}
.slotcontent {
  margin: 10rpx 5px;
  display: flex;
  align-items: center;
  font-size: 28rpx; 
}

.slotcontent text{
  color: mediumpurple ;
  margin-right: 10rpx;

}

.borderbox {
  border: 1rpx solid gray;
  border-radius: 10rpx;
  margin: 0 8rpx;
  
}
</style>